package com.base.controller;

import javax.servlet.http.HttpServletRequest;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;
import com.base.po.voip.Share;
import com.base.service.ShareService;

/**
 * 分享信息服务端
 * 
 * @author 
 *
 */
@Controller
@RequestMapping("/admin")
public class index_Share {

	@Autowired
	private ShareService shareService; // 分享页图片

	// 分享图片首页
	@RequestMapping("/shareIndex")
	public ModelAndView carouselIndex(HttpServletRequest request) throws Exception {
		String userid = (String) request.getSession().getAttribute("adminUserId"); // 登录的用户ID
		if (userid == null) return new ModelAndView("jsp/loginCheck");  // 未登录
		return new ModelAndView("jsp/index_Share", "list",
				shareService.selectByAll(new Share(userid, (byte)1)));
	}

	// 跳转添加分享图片
	@RequestMapping("/addShare")
	public ModelAndView addShare(HttpServletRequest request) throws Exception {
		ModelAndView modelAndView = new ModelAndView();
		modelAndView.setViewName("jsp/add_Share");
		request.setAttribute("toleft", 258);
		request.setAttribute("totop", 834);
		request.setAttribute("qrcodesize", 234);
		return modelAndView;
	}

	// 跳转修改分享图片
	@RequestMapping("/updateShare")
	public ModelAndView updateShare(String id) throws Exception {
		return new ModelAndView("jsp/update_Share", "share", shareService.selectByPrimaryKey(id));
	}
}
